﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameEngine.Scenes;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GameEngine.Managers.IManagers;
using GameEngine.Entities;
using PvT.Entities;
using GameEngine.EntityComponents;

namespace PvT.Scenes
{
    public class Past : Scene
    {
        public Past(Game game)
            : base(game)
        {
            CollisionMap = game.Content.Load<Texture2D>("Scenes/Past/PastCollisionMap");
            background = game.Content.Load<Texture2D>("Scenes/Past/environment");
            DeathTrapMap = game.Content.Load<Texture2D>("Scenes/Past/pastDangerZones");
            backgroundSound = "Sound/RunescapeArabian3";
        }

        public override void PauseAction()
        {
            ISceneManager scene = (ISceneManager)game.Services.GetService(typeof(ISceneManager));
            scene.PushScene(new PauseScreen(game));
        }

        public override void Update(GameTime gameTime)
        {
            foreach(AbstractEntity entity in GetSceneObjects()) {
                if(entity.GetType() == typeof(PlayerEntity)) {
                    if (!(((TerminateableComponent)entity.GetComponent(typeof(TerminateableComponent))).IsAlive()))
                    {
                        ISceneManager scene = (ISceneManager)game.Services.GetService(typeof(ISceneManager));
                        scene.PushScene(new GameOverScreen(game));
                    }
                }
            }

            base.Update(gameTime);
        }
    }
}
